package com.og.managedbean;

import java.io.Serializable;

import javax.enterprise.context.SessionScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;

import com.og.backingbean.Version;
import com.og.dao.CRUDEntityDAO;

/**
 * @author Renaud DIANA
 *
 */
@Named
@SessionScoped
public class VersionBean implements Serializable {

	private static final long serialVersionUID = 1L;
	
	/* Dependency injection */
	// Model
    @Inject
    CRUDEntityDAO<Version> addVersion;
    // BackingBean
    @Inject
    Version version;

	/**
	 * Default constructor
	 */
	public VersionBean() {
		// TODO Auto-generated constructor stub
	}
	
	public String create() {
				
		// Call model				
		addVersion.createEntity(version);
		
		// Add message
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Add version Successful"));  
		
		// Navigation case
		return "";
		//return "success";
	}


	public Version getVersion() {
		return version;
	}

	public void setVersion(Version version) {
		this.version = version;
	}

}
